package com.orange.quickback.demo3;

import com.orange.quickback.system.api.common.result.QBootResult;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "Student")
@RestController
@RequestMapping("/Student/")
public class StudentController {
    @Resource
    StudentServiceImpl studentService;
    @GetMapping("/getAllStudents")
    public QBootResult getAllStudents() {
        return studentService.getAllStudents();
    }
    @PostMapping("/getStudentById")
    public QBootResult getStudentsById(@RequestParam String id){
        return studentService.getStudentById(Long.valueOf(id));
    }
    @PostMapping("/saveStudent")
    public QBootResult saveStudent(@RequestBody Student student){
        return studentService.saveStudent(student);
    }
    @PostMapping("/saveStudents")
    public QBootResult saveStudents(@RequestBody List<Student> students){
        return studentService.saveStudents(students);
    }
    @PostMapping("/getStudentsByPage")
    public QBootResult getStudentsByPage(@RequestParam int page, @RequestParam int size){
        return studentService.getStudentsByPage(page,size);
    }
    @PostMapping("/getStudentsByPageDesc")
    public QBootResult getStudentsByPageDesc(@RequestParam  int page,@RequestParam int size){
        return studentService.getStudentsByPageDesc(page,size);
    }
    @PostMapping("/deleteStudentById")
    public QBootResult deleteStudentById(@RequestParam String id){
        return studentService.deleteStudentById(Long.valueOf(id));
    }
    @PostMapping("/deleteStudent")
    public QBootResult deleteStudent(@RequestBody Student student){
        return studentService.deleteStudent(student);
    }
}
